/******************************************************************************/
/* @ All Rights Reserved Copyright (C) 2014 broada,Ltd.                       */
/*                                                                            */
/*  NAME      = fix_comm.h                                                    */
/*  NOTE      =                                                               */
/*  DATE      = 2015/10/18 by zhengxd                                         */
/******************************************************************************/
#ifndef __FIX_BASE_TYPE_H_
#define __FIX_BASE_TYPE_H_

#include "frmem.h"
#include "frstr.h"
#include "frcomm.h"
#include "frlist.h"
#include "frhash2.h"
#include "frlog.h"
#include "iconv2utf8.h"
#include "frsutl.h"
#include "frhex_dump.h"

#include "conntrack.h"
#include "module.h"
#include "frct_comm.h"
#include "frreport_comm.h"
#include "frdb_cursor.h"
#include "frbyte_buffer.h"
#include "frtds_convert.h"


/* 此三条需要特别注意不要和下面的定义重复,属于为了方便自增 */
#define POSTGRESQL_TP_STARTUP                  1
#define POSTGRESQL_TP_CANCEL_REQ               2
#define POSTGRESQL_TP_SSL_REQ                  3
/*
*  AuthenticationOk/AuthenticationKerberosV5
*  /AuthenticationCleartextPassword/AuthenticationMD5Password
*  /AuthenticationSCMCredential/AuthenticationGSS
*  /AuthenticationSSPI/AuthenticationGSSContinue
*/
#define POSTGRESQL_TP_AUTHENTICATION           'R'
#define POSTGRESQL_TP_BACKEND_KEY_DATA         'K'
#define POSTGRESQL_TP_BIND                     'B'
#define POSTGRESQL_TP_BIND_COMPLETE            '2'
#define POSTGRESQL_TP_CLOSE                    'C'
#define POSTGRESQL_TP_CLOSE_COMPLETE           '3'
#define POSTGRESQL_TP_COMMAND_COMPLETE         'C'
#define POSTGRESQL_TP_COPY_DATA                'd'
#define POSTGRESQL_TP_COPY_DONE                'c'
#define POSTGRESQL_TP_COPY_FAIL                'f'
#define POSTGRESQL_TP_COPY_IN_RESP             'G'
#define POSTGRESQL_TP_COPY_OUT_RESP            'H'
#define POSTGRESQL_TP_DATA_ROW                 'D'
#define POSTGRESQL_TP_DESCRIBE                 'D'
#define POSTGRESQL_TP_EMPTY_QUERY_RESP         'I'
#define POSTGRESQL_TP_ERROR_RESP               'E'
#define POSTGRESQL_TP_EXECUTE                  'E'
#define POSTGRESQL_TP_FLUSH                    'H'
#define POSTGRESQL_TP_FUNCTION_CALL            'F'
#define POSTGRESQL_TP_FUNCTION_CALL_RESP       'V'
#define POSTGRESQL_TP_NO_DATA                  'n'
#define POSTGRESQL_TP_NOTICE_RESP              'N'
#define POSTGRESQL_TP_NOTIFICATION_RESP        'A'
#define POSTGRESQL_TP_PARAMETER_DESCRIPTION    't'
#define POSTGRESQL_TP_PARAMETER_STATUS         'S'
#define POSTGRESQL_TP_PARSE                    'P'
#define POSTGRESQL_TP_PARSE_COMPLETE           '1'
#define POSTGRESQL_TP_PASSWORD_MSG             'p'
#define POSTGRESQL_TP_PORTAL_SUSPENDED         's'
#define POSTGRESQL_TP_QUERY                    'Q'
#define POSTGRESQL_TP_READY_QUERY              'Z'
#define POSTGRESQL_TP_ROW_DESCRIPTION          'T'
#define POSTGRESQL_TP_SYNC                     'S'
#define POSTGRESQL_TP_TERMINATE                'X'

/* 请求command列表 */
typedef struct __st_postgresql_req_cmd {

    int i_new_flg;
    int i_req_type;
    int i_report_flg;
    int i_packet_len;
    long l_err_code;
    char *p_err_msg;
    char *p_cursor_str;
    Sql_statement *p_st_statement;        /* 当前DDM的对应游标数据 */
    Sql_resultset *p_st_resultset;        /* 当前DDM的对应结果集索引 */
    struct timeval st_start_timestamp;   /* 开始分片包的时间 */
    struct timeval st_end_timestamp;     /* 分片包结束的时间 */
} Postgresql_req_cmd;

#endif
